import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

showAlert({String title = '', String message = '', String? okText, String? cancelText, Function? onOk, Function? onCancel}) {
  showCupertinoDialog(context: Get.context!, builder: (ctx){
    return CupertinoAlertDialog(
      title: Text(title),
      content: Text(message),
      actions: [
        if (cancelText != null)
          CupertinoDialogAction(
            child: Text(cancelText),
            onPressed: () {
              if (onCancel != null) {
                onCancel();
              }
              Get.back();
            },
          ),
        CupertinoDialogAction(
          child: Text(okText ?? 'OK'),
          onPressed: () {
            Get.back();
            if (onOk != null) {
              onOk();
            }
          },
        ),
      ],
    );
  });
}